package com.xjy.service;

import com.github.pagehelper.PageHelper;
import com.xjy.dao.userMapper;
import com.xjy.pojo.Cart;
import com.xjy.pojo.User;
import com.xjy.pojo.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class userServiceImpl implements userService{
    //service调dao层
    @Autowired
    private userMapper userMapper;
    public void setUserMapper(userMapper mapper) {
        this.userMapper = mapper;
    }


    @Override
    public List<User> getUsers() {
        return userMapper.getUsers();
    }

    @Override
    public User getUserByName(String name) {
        return userMapper.getUserByName(name);
    }

    @Override
    public User getUserById(int id) {
        return userMapper.getUserById(id);
    }

    @Override
    public int userRegister(User user) {
        return userMapper.userRegister(user);
    }

    @Override
    public int userUpdate(User user) {
        return userMapper.userUpdate(user);
    }

    @Override
    public int userDelete(int uid) {
        return userMapper.userDelete(uid);
    }

    @Override
    public List<User> findAllUsersByPage(Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage, pageSize);
        return userMapper.getUsers();
    }

    @Override
    public UserInfo getUserInfo(int uid) {
        return userMapper.getUserInfo(uid);
    }


}
